<?php
		require('config.php');
        $goods_id=$_REQUEST['goods_id'];
        $isGoodsContent=0;
        if(isset($_REQUEST['isGoodsContent'])) $isGoodsContent=$_REQUEST['isGoodsContent'];
		$sql="select * from `".$oto."_goods` where `goodsId`='".$goods_id."' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$goods_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$time=time();
        $t1=strtotime(date('Y-m-d 00:00:00',$time));
        $t2=strtotime(date('Y-m-d 08:00:00',$time));
        $t3=strtotime(date('Y-m-d 12:00:00',$time));
        $t4=strtotime(date('Y-m-d 16:00:00',$time));
        $t5=strtotime(date('Y-m-d 20:00:00',$time));
        $t6=strtotime(date('Y-m-d 24:00:00',$time));
        $data[0]['pan']=-1;
		if($time<$t2 && $time>=$t1)
		{
			$pan=1;
			$stat_time=$t1;
			$end_time=$t2;
		}
		if($time<$t3 && $time>=$t2)
		{
			$pan=2;
			$stat_time=$t2;
			$end_time=$t3;
		}
		if($time<$t4 && $time>=$t3)
		{
			$pan=3;
			$stat_time=$t3;
			$end_time=$t4;
		}
		if($time<$t5 && $time>=$t4)
		{
			$pan=4;
			$stat_time=$t4;
			$end_time=$t5;
		}
		if($time<$t6 && $time>=$t5)
		{
			$pan=5;
			$stat_time=$t5;
			$end_time=$t6;
		}
		$pan2=$pan-1;
        //$sql="select * from ".$oto."_goods,".$oto."_goods_seckill where ".$oto."_goods.isSeckill='1' and ".$oto."_goods.goodsId=".$oto."_goods_seckill.goodsId and ".$oto."_goods.shopId=".$oto."_goods_seckill.shopId and seckillStartTime>='{$stat_time}' and seckillEndTime<='{$end_time}' and ".$oto."_goods.goodsId='{$goods_id}'";
        $sql="select shop.userTalkLink,s.seckillPrice,s.goodsId,s.shopId,s.seckillStartTime,s.seckillStartTime,s.seckillEndTime,g.goodsDesc,s.seckillMaxCount,g.goodsName,g.goodsImg,shop.shopImg,shop.shopName from ".$oto."_goods as g,".$oto."_goods_seckill as s,".$oto."_shops as shop where g.isSeckill='1' and g.goodsId=s.goodsId and g.shopId=s.shopId and s.seckillStartTime<='{$time}' and s.seckillEndTime>'{$time}' and s.seckillSetTime='{$pan2}' and g.goodsId='{$goods_id}' and g.shopId=shop.shopId";
        //file_put_contents("tsxx.txt", "\r\n".$sql."\r\n", FILE_APPEND);
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$miaosha_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($miaosha_info))
		{
			echo '[]';
		}
		else
		{
			$miaosha_info[0]['shopPrice']=$miaosha_info[0]['seckillPrice'];
			$miaosha_info[0]['goodsStock']=$miaosha_info[0]['seckillMaxCount'];
			$miaosha_info[0]['seckillMaxCount']=$miaosha_info[0]['seckillMaxCount'];
			$miaosha_info[0]['goodsDesc']=htmlspecialchars_decode($miaosha_info[0]['goodsDesc']);
			$time_star=time();
			$time_end=$time_star-3600*24*30;
			$time_star1=date('Y-m-d H:i:s',$time_end);
			$time_end1=date('Y-m-d H:i:s',$time_star);
			$seckillStartTime=$miaosha_info[0]['seckillStartTime'];
			$seckillEndTime=$miaosha_info[0]['seckillEndTime'];
			$sql="select * from `".$oto."_orders`,`".$oto."_order_goods` where ".$oto."_orders.orderId=".$oto."_order_goods.orderId and ".$oto."_order_goods.goodsId='{$goods_id}' and createTime>='$seckillStartTime' and createTime<='$seckillEndTime' and orderStatus='4'";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$order_list[]=$row;//将取得的所有数据赋值给person_info数组
			}
			$sum=0;
			if(isset($order_list))
			{
				for($i=0;$i<count($order_list);$i++)
				{
					$sum+=$order_list[$i]['goodsNums'];
				}
			}
			$miaosha_info[0]['yue_xiaoliang']=$sum;
			$miaosha_info[0]['time']=$time;
			$miaosha_info[0]['goodsId']=$goods_id;
			if($isGoodsContent!=0) $miaosha_info[0]['goodsDesc']="";
			echo json_encode($miaosha_info);
		}
		
?>